// #include <stdint.h>
// #include<stdio.h>

/**
 * Common Data Types
 *
 * The data types in this section are essentially aliases for C/C++
 * primitive data types.
 *
 * Adapted from http://msdn.microsoft.com/en-us/library/cc230309.aspx.
 * See http://en.wikipedia.org/wiki/Stdint.h for more on stdint.h.
 */
typedef unsigned char  BYTE;
typedef unsigned short WORD;
typedef unsigned long  DWORD;
typedef long LONG;
 
 //__attribute__ ((packed))好像只能保证去除末尾填充,并不能保证对齐
/**
 * BITMAPFILEHEADER
 *
 * The BITMAPFILEHEADER structure contains information about the type, size,
 * and layout of a file that contains a DIB [device-independent bitmap].
 *
 * Adapted from http://msdn.microsoft.com/en-us/library/dd183374(VS.85).aspx.
 */
//不加两行头文件需要用这句,否则不需要
// #pragma pack(1)
typedef struct {
    WORD bfType;
    DWORD  bfSize;          //文件大小  
    WORD   bfReserved1;     //保留字，不考虑  
    WORD   bfReserved2;     //保留字，同上  
    DWORD  bfOffBits;       //实际位图数据的偏移字节数，即前三个部分长度之和  
}BITMAPFILEHEADER;

/**
 * BITMAPINFOHEADER
 *
 * The BITMAPINFOHEADER structure contains information about the
 * dimensions and color format of a DIB [device-independent bitmap].
 *
 * Adapted from http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx.
 */
typedef struct  {
    DWORD   biSize;             //指定此结构体的长度，为40  
    LONG    biWidth;            //位图宽  
    LONG    biHeight;           //位图高  
    WORD    biPlanes;           //平面数，为1  
    WORD    biBitCount;         //采用颜色位数，可以是1，2，4，8，16，24，新的可以是32  
    DWORD   biCompression;      //压缩方式，可以是0，1，2，其中0表示不压缩  
    DWORD   biSizeImage;        //实际位图数据占用的字节数  
    LONG    biXPelsPerMeter;    //X方向分辨率  
    LONG    biYPelsPerMeter;    //Y方向分辨率  
    DWORD   biClrUsed;          //使用的颜色数，如果为0，则表示默认值(2^颜色位数)  
    DWORD   biClrImportant;     //重要颜色数，如果为0，则表示所有颜色都是重要的  
}BITMAPINFOHEADER;

/**
 * RGBTRIPLE
 *
 * This structure describes a color consisting of relative intensities of
 * red, green, and blue.
 *
 * Adapted from http://msdn.microsoft.com/en-us/library/aa922590.aspx.
 */
typedef struct
{
    BYTE  rgbtBlue;
    BYTE  rgbtGreen;
    BYTE  rgbtRed;
}RGBTRIPLE;